home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / listx / cdraw.cls < prev    next >
Text File  |  1997-11-12  |  5KB  |  154 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "CDraw"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9. '
  10. ' Pictures painted in various places, set by owndraw.drm
  11. '
  12. Public m_Picture1 As PictureBox
  13. Public m_Picture2 As PictureBox
  14. Public m_Picture3 As PictureBox
  15. Public m_Picture4 As PictureBox
  16.  
  17. Public Function IMCaptionPaint_CaptionHeight(height As Integer) As Boolean
  18.    '
  19.    ' List/X+ control needs to know the caption height
  20.    '
  21.    m_Picture2.ScaleMode = Pixel
  22.    height = m_Picture2.ScaleHeight + 3
  23.    '
  24.    ' Let the control know that the return value is valid
  25.    '
  26.    IMCaptionPaint_CaptionHeight = True
  27. End Function
  28.  
  29.  
  30. Public Function IMListPaint_ItemHeight(ByVal itemnum As Long, height As Integer) As Boolean
  31.    If (itemnum >= 0) Then
  32.       '
  33.       ' List height
  34.       '
  35.       m_Picture1.ScaleMode = Pixel
  36.       height = m_Picture1.ScaleHeight
  37.    Else
  38.       '
  39.       ' Heading height
  40.       '
  41.       m_Picture3.ScaleMode = Pixel
  42.       height = m_Picture3.ScaleHeight
  43.    End If
  44.    IMListPaint_ItemHeight = True
  45. End Function
  46.  
  47. Public Function IMCaptionPaint_PaintCaption(ByVal MPicture As MabryCtl.IMPicture) As Boolean
  48.    Dim h As Integer
  49.    Dim w As Integer
  50.    Dim x As Integer
  51.    Dim y As Integer
  52.    Dim s As String
  53.    
  54.    s = "List/X+ Rules"
  55.    
  56.    MPicture.ScaleMode = Pixel
  57.    MPicture.PaintPicture m_Picture2.Picture, 0, 2, 24, 24
  58.    
  59.    h = MPicture.TextHeight(s)
  60.    w = MPicture.TextWidth(s)
  61.    
  62.    x = 32
  63.    y = (MPicture.ScaleHeight - h) / 2
  64.    
  65.    MPicture.FontTransparent = True
  66.    MPicture.ForeColor = RGB(255, 255, 255)
  67.    MPicture.DrawText s, x - 1, y - 1, x + w - 1, y + h - 1, 0
  68.    MPicture.ForeColor = RGB(128, 128, 128)
  69.    MPicture.DrawText s, x + 1, y + 1, x + w + 1, y + h + 1, 0
  70.    MPicture.ForeColor = RGB(0, 0, 0)
  71.    MPicture.DrawText s, x, y, x + w, y + h, 0
  72.  
  73.    IMCaptionPaint_PaintCaption = True
  74. End Function
  75. Public Function IMListPaint_PaintColumn(ByVal MPicture As MabryCtl.IMPicture, ByVal Item As Long, ByVal Column As Long, ByVal Selected As Boolean) As Boolean
  76.    Dim s As String
  77.    Dim h As Integer
  78.    Dim w As Integer
  79.    Dim x As Integer
  80.    Dim y As Integer
  81.        
  82.    MPicture.ScaleMode = Pixel
  83.    '
  84.    ' Handle headings here
  85.    '
  86.    If (Item = -1) Then
  87.       Select Case Column
  88.          Case 0:
  89.             IMListPaint_PaintColumn = True
  90.          Case 1:
  91.             s = "Text && Graphics!"
  92.    
  93.             MPicture.ScaleMode = Pixel
  94.    
  95.             h = MPicture.TextHeight(s)
  96.             w = MPicture.TextWidth(s)
  97.    
  98.             x = 0
  99.             y = (MPicture.ScaleHeight - h) / 2
  100.             MPicture.DrawText s, x, y, x + w, y + h, 0
  101.             
  102.             m_Picture4.ScaleMode = Pixel
  103.             MPicture.PaintPicture m_Picture4.Picture, MPicture.ScaleWidth - m_Picture4.ScaleWidth, 0, m_Picture4.ScaleWidth, m_Picture4.ScaleHeight
  104.             IMListPaint_PaintColumn = True
  105.          Case 2:
  106.             MPicture.PaintPicture m_Picture3.Picture, 0, 0, 20, 23
  107.             IMListPaint_PaintColumn = True
  108.          Case Else
  109.             IMListPaint_PaintColumn = False
  110.       End Select
  111.       Exit Function
  112.    End If
  113.    '
  114.    ' Painting the list itself
  115.    '
  116.    IMListPaint_PaintColumn = True
  117.    Select Case Column
  118.       Case 0:
  119.          '
  120.          ' stretchs to fit column
  121.          '
  122.          MPicture.PaintPicture m_Picture1.Picture, 0, 0
  123.          '
  124.          ' no stretch
  125.          '
  126. '         MPicture.PaintPicture Picture1.Picture, 0, 0, 32, 32
  127.       Case 1:
  128.          MPicture.Font = m_Picture1.Font
  129.          
  130.          If (Selected) Then
  131.             MPicture.ForeColor = RGB(255, 192, 0)
  132.          Else
  133.             MPicture.ForeColor = RGB(0, 128, 0)
  134.          End If
  135.          
  136.          If (Item Mod 3) = 0 Then
  137.             MPicture.DrawText "Cool!", 0, 0, MPicture.ScaleWidth, MPicture.ScaleHeight, tfSingleLine Or tfVertCenter Or tfCenter
  138.          Else
  139.             MPicture.DrawText "Line " & CStr(Item), 0, 0, MPicture.ScaleWidth, MPicture.ScaleHeight, tfSingleLine Or tfVertCenter Or tfCenter
  140.          End If
  141.       Case 2:
  142.          MPicture.CurrentX = 0
  143.          MPicture.CurrentY = 0
  144.          MPicture.FillStyle = Item Mod 8
  145.          MPicture.FillColor = RGB(0, 0, 192)
  146.          MPicture.ForeColor = RGB(0, 0, 192)
  147.          MPicture.Line -Step(MPicture.ScaleWidth, MPicture.ScaleHeight), , BF
  148.       Case Else
  149.          IMListPaint_PaintColumn = False
  150.    End Select
  151. End Function
  152.  
  153.  
  154.